code for the approximation